<!-- 研发查看验工计价页面 -->
<template>
  <div ref="getInspectInfo" style="padding: 10px 15px;">
    <div v-if="this.$route.query.type === 'todo'" style="text-align: right;margin: 15px 5px 15px 0;"><el-button
      class="pms-button-primary"
      @click="handleClick()"
    >操作验工计价</el-button></div>
    <el-table ref="table" :data="tableData" border>
      <el-table-column align="center" type="index" label="序号" width="50" />
      <el-table-column
        v-for="(item, index) in tableColumn"
        :key="index"
        align="center"
        :prop="item.prop"
        :label="item.label"
        width="200"
      >
        <template slot-scope="scope">
          <el-tooltip effect="dark" :content="scope.row[item.prop]+''" placement="top">
            <span class="header-tooltip">{{ scope.row[item.prop] }}</span>
          </el-tooltip>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
const tableColumn = [{
  prop: 'SERVICECODE',
  label: '服务编码'
}, {
  prop: 'SERVICENAME',
  label: '服务名称'
}, {
  prop: 'SUPPLIER',
  label: '供应商名称'
}, {
  prop: 'ORDERCODE',
  label: '订单编码'
}, {
  prop: 'CONTRACTCODE',
  label: '合同编码'
}, {
  prop: 'SHNUM',
  label: '商合预占数'
}, {
  prop: 'PRICE',
  label: '单价(元)'
}, {
  prop: 'SHMONEY',
  label: '商合预占金额(元)'
}, {
  prop: 'SUMNUM',
  label: '累计验工数量'
}, {
  prop: 'SUMMONEY',
  label: '累计验工金额'
}, {
  prop: 'REMAININGNUM',
  label: '可发起验工数量'
}]
import { getInsValTable } from '@/api/checkoutValuation/index'
export default {
  data() {
    return {
      tableColumn,
      tableData: []
    }
  },
  created() {
    this.initTable()
  },
  methods: {
    async initTable() {
      const { code, data } = await getInsValTable({ prjId: this.$route.query.prjId })
      if (+code === 200) {
        this.tableData = data
        this.$nextTick(() => {
          const params = {
            height: this.$refs.getInspectInfo.clientHeight,
            type: 'getInspectInfo'
          }
          console.log(params, 'getInspectInfo=>验工计价初始化发送高度')
          window.parent.postMessage(params, this.$fixIframeArr())
        })
      }
    },
    handleClick() {
      const { prjId, manageMode } = this.$route.query
      window.open(`${process.env.VUE_APP_ZHONGRUAN_URL}checkoutValuationOperationDetail?prjId=${prjId}&newOldProject=1&manageMode=${manageMode}`, '_blank')
    }
  }
}

</script>
<style scoped></style>
